package com.xyhuo.leetcode.proxy.dynamicProxy;

import com.xyhuo.leetcode.proxy.staticProxy.Person;
import com.xyhuo.leetcode.proxy.staticProxy.Student;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class ProxyTest {

    public static void main(String[] args) {
        Person zhangsan = new Student("张三");

        InvocationHandler stuHandler = new StudentInvocationHandler<Person>(zhangsan);

        Person stuProxy = (Person) Proxy.newProxyInstance(Person.class.getClassLoader(), new Class<?>[]{Person.class}, stuHandler);

        stuProxy.giveMoney();
    }

}
